<script>
  $(document).ready(function(){
	  $("#name").keyup(function(){
          var name = $(this).val();
          if(name==""){
       	   var str="<font color='red'>&nbsp;公司名不能空！</font>";
              $("#name_notice").html('');
              $("#name_notice").html(str);
          }else{
	           $.ajax({
		    	   type: "POST",
		    	   url: "<?php echo base_url();?>administrator/auth",
		    	   data: "name="+name+"&type=company",
		    	   success: function(msg){
		    		    if(msg>=1){
	                        var str="<font color='red'>&nbsp;此公司名已经存在，请更改！</font>";
	                    }else{
	                    	var str="<font color='green'>&nbsp;此公司名可使用！</font>";
	                    }
	                    $("#name_notice").html('');
	                    $("#name_notice").html(str);
		    	   }
		    	}); 
          }
      })
      
      $("#name").blur(function(){
          var name = $(this).val();
          if(name==""){
       	   var str="<font color='red'>&nbsp;公司名不能空！</font>";
              $("#name_notice").html('');
              $("#name_notice").html(str);
          }else{
	           $.ajax({
		    	   type: "POST",
		    	   url: "<?php echo base_url();?>administrator/auth",
		    	   data: "name="+name+"&type=company",
		    	   success: function(msg){
		    		   if(msg>=1){
	                       var str="<font color='red'>&nbsp;此公司名已经存在，请更改！</font>";
	                   }else{
	                   	   var str="<font color='green'>&nbsp;此公司名可使用！</font>";
	                   }
	                   $("#name_notice").html('');
	                   $("#name_notice").html(str);
		    	   }
		    	}); 
          }	
      })
	  
     $("#submit").click(function(){
         var name = $("#name").val();
         if(name==""){
        	   var str="<font color='red'>版本名称不能空！</font>";
               $("#name_notice").html('');
               $("#name_notice").html(str);
               return false;
         } 
     })
  })
</script>
<div id="center-column">
			<div class="top-bar">
				<a href="<?php echo  base_url();?>administrator/company_add" class="button">新增</a>
				<h1>Contents</h1>
				<div class="breadcrumbs"><?php echo anchor('main/index','首页');?> /<?php echo anchor('administrator/company_add','添加发放单位');?></div>
			</div>
			
		  <div class="table add_table">
				
				
				<table class="listing form" cellpadding="0" cellspacing="0">
				  <?php if(isset($id)){echo form_open('administrator/company_edit/'.$id);}else{echo form_open('administrator/company_add');}?>
					<tr>
						<th  colspan="2"  align="center"><?php if(isset($id)){?>编辑发放单位<?php }else{?>新增发放单位<?php }?></th>
					</tr>
					<tr>
						<td class="first" width="172"><strong>单位名称：</strong></td>
						<td class="last"><input type="text" class="text" name="name" id="name" value="<?php if(isset($id)){echo $company->name;}?>" /><span id="name_notice"></span></td>
					</tr>
					<tr class="bg">
						<td class="first"><strong>单位地址：</strong></td>
						<td class="last"><input type="text" class="text" name="address" value="<?php if(isset($id)){echo $company->address;}?>" /></td>
					</tr>
					<tr class="bg">
						<td class="first""><strong>单位联系人：</strong></td>
						<td class="last"><input name='contacter'  class="text" value="<?php if(isset($id)){echo $company->contacter;}?>" /></td>
					</tr>
					<tr class="bg">
						<td class="first"><strong>单位电话：</strong></td>
						<td class="last"><input type="text" class="text" name="phone" value="<?php if(isset($id)){echo $company->phone;}?>" /></td>
					</tr>
					<tr>
						<td colspan="2" style="text-align:center;"><input type="submit" value="提交" class="button" id="submit"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="返回" class="button" onclick="location.href='<?php echo site_url()?>administrator/company'" /></td>			
					</tr>
				</form>	
				</table>
	        <p>&nbsp;</p>
		  </div>
		</div>
	</div>
	<div id="footer"></div>
</div>



</body>
</html>
